
#import "LBNativeViewController.h"
#import <LbAdSdk/ADv.h>
#import "Config.h"

@interface LBNativeViewController () <NativeDelegate>
@property (nonatomic, strong) NativeAD* nativeAD;
@end

@implementation LBNativeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self showAD];
}

- (void)showAD{
    NativeConfiguration *config = [[NativeConfiguration alloc] init];
    config.ADFrame = CGRectMake(.0f, 100.0f, CGRectGetWidth(self.view.bounds), 350.0f);
    config.mediaViewFrame = CGRectMake(.0f, 120.0f, CGRectGetWidth(self.view.bounds), 200.0f - 120.0f);
    config.sizeToFit=NO;
    config.rootViewController = self;
    _nativeAD  =  [ADv showNativeAD:LB_TEST_NATIVE_ID containerView:self.view configuration:config delegate:self];
}


- (void)reloadAD{
    [_nativeAD reload];
}


// MARK: -loading
- (void)didFailToLoadADWithPlacementID:(NSString *)placementID error:(NSError *)error {
    NSLog(@"NativeViewController::didFailToLoadADWithPlacementID:%@ error:%@",placementID,error);
}

- (void)didFinishLoadingADWithPlacementID:(NSString *)placementID {
    NSLog(@"NativeViewController::didFinishLoadingADWithPlacementID:%@",placementID);
}

// MARK:-native
-(void) didClickNativeAdInAdView:(UIView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
    NSLog(@"NativeViewController:: didClickNativeAdInAdView:placementID:%@ with extra: %@", placementID,extra);
}

-(void) didShowNativeAdInAdView:(UIView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
    NSLog(@"NativeViewController:: didShowNativeAdInAdView:placementID:%@ with extra: %@", placementID,extra);
}

-(void) didTapCloseButtonInAdView:(UIView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra {
    NSLog(@"NativeViewController:: didTapCloseButtonInAdView:placementID:%@ extra:%@", placementID, extra);
    [_nativeAD clear];
}




@end
